<?php
/**
 * Resource file for Locale
 */
class BRail_Application_Resource_Locale extends Zend_Application_Resource_Locale
{
    /**
     * Test if we there is a locale cookie and then retrieve the locale object
     *
     * @return Zend_Locale
     */
    public function getLocale()
    {
        if (isset($_COOKIE[Application::code . '_locale'])
            && in_array($_COOKIE[Application::code . '_locale'], Application::getLocales())) {
            $this->setOptions(array('force' => true,
                                    'default' => $_COOKIE[Application::code . '_locale']));
        }
        return parent::getLocale();
    }
}